using FluentNHibernate.AutoMap;
using FluentNHibernate.Conventions;
using FluentNHibernate.Mapping;
using Web.App.Infrastructure.ObjectStore.Contracts;
using Webshop20.Domain.Catalog.Core;

namespace Webshop20.Infrastructure.Persistence.NH.AutoMappings.Conventions.Particular
{
    public class ObjectStoreItemConventions : IClassConvention
    {
        public bool Accept(IClassMap target)
        {
            return target.EntityType.Name == typeof(ObjectStoreItem).Name;
        }

        public void Apply(IClassMap target)
        {
            var autoMap = (AutoMap<ObjectStoreItem>)target;
            autoMap.Map(x => x.Data)
                .CustomSqlTypeIs("Binary")
                .WithLengthOf(1000000000);

        }
    }
}